//package com.platform.tony.config;
//
//import cn.hutool.core.util.StrUtil;
//import com.platform.tony.common.Constant;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.security.authentication.InternalAuthenticationServiceException;
//import org.springframework.stereotype.Component;
//import org.springframework.web.filter.OncePerRequestFilter;
//
//import javax.servlet.FilterChain;
//import javax.servlet.ServletException;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//
//
//@Slf4j
//@Component
//public class PhoneCodeFilter extends OncePerRequestFilter {
//
//
//    @Autowired
//    private AppFailureHandler failureHandler;
//
//
//    @Override
//    protected void doFilterInternal(HttpServletRequest request,
//                                    HttpServletResponse response, FilterChain chain)
//            throws ServletException, IOException {
//
//        // 手机验证码
//        String code = request.getParameter("code");
//        String cellphone = request.getParameter("cellphone");
//        log.info("uri {} cellphone {} and code {}", request.getRequestURI(), cellphone, code);
//
//        if (StrUtil.equals(Constant.PHONE_URI, request.getRequestURI())) {
//            // 验证手机验证码
//            if (!StrUtil.equals(code, "123456")) {
//                failureHandler.onAuthenticationFailure(request, response, new InternalAuthenticationServiceException("验证码失效!"));
//            }
//
//        }
//
//        chain.doFilter(request, response);
//
//
//    }
//}
